{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tkinter\n",
    "import threading\n",
    "import datetime\n",
    "import time\n",
    "app=tkinter.Tk()\n",
    "app.overrideredirect(True)\n",
    "app.attributes('-alpha',0.9)\n",
    "app.attributes('-topmost',1)\n",
    "app.geometry('110x25+100+100')\n",
    "labelDateTime=tkinter.Label(app)\n",
    "labelDateTime.pack(fill=tkinter.BOTH,expand=tkinter.YES)\n",
    "labelDateTime.configure(bg='gray')\n",
    "X=tkinter.IntVar(value=0)\n",
    "Y=tkinter.IntVar(value=0)\n",
    "canMove=tkinter.IntVar(value=0)\n",
    "still=tkinter.IntVar(value=1)\n",
    "def onLeftButtonDown(event):\n",
    "    app.attributes('-alpha',0.4)\n",
    "    X.set(event.x)\n",
    "    Y.set(event.y)\n",
    "    canMove.set(1)\n",
    "labelDateTime.bind('<Button-1>',onLeftButtonDown)\n",
    "def onLeftButtonUp(event):\n",
    "    app.attributes('-alpha',0.9)\n",
    "    canMove.set(0)\n",
    "labelDateTime.bind('<ButtonRelease-1>',onLeftButtonUp)\n",
    "def onLeftButtonMove(event):\n",
    "    if canMove.get()==0:\n",
    "        return\n",
    "    newX=app.winfo_x()+event.x-X.get()\n",
    "    newY=app.winfo_y()+event.y-Y.get()\n",
    "    g='110x25+'+str(newX)+'+'+str(newY)\n",
    "    app.geometry(g)\n",
    "labelDateTime.bind('<B1-Motion>',onLeftButtonMove)\n",
    "def onRightButtonDown(event):\n",
    "    still.set(0)\n",
    "    t.join(0.2)\n",
    "    app.destroy()\n",
    "labelDateTime.bind('<Button-3>',onRightButtonDown)\n",
    "def nowDateTime():\n",
    "    while still.get()==1:\n",
    "        now=datetime.datetime.now()\n",
    "        s=str(now.year)+'-'+str(now.month)+'-'+str(now.day)+' '\n",
    "        s=s+str(now.hour)+':'+str(now.minute)+':'+str(now.second)\n",
    "        labelDateTime.config(text=s)\n",
    "        time.sleep(0.5)\n",
    "t=threading.Thread(target=nowDateTime)\n",
    "t.daemon=True\n",
    "t.start()\n",
    "app.mainloop()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
